home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 November: Tool Chest / Dev.CD Nov 00 TC Disk 1.toast / Sample Code / Contributed / SpriteWorld / SpriteWorld Files / Headers / SpriteFrame.h < prev    next >
Encoding:
Text File  |  2000-10-06  |  7.0 KB  |  248 lines  |  [TEXT/CWIE]

  1. ///--------------------------------------------------------------------------------------
  2. //    SpriteFrame.h
  3. //
  4. //    Portions are copyright: © 1991-94 Tony Myles, All rights reserved worldwide.
  5. ///--------------------------------------------------------------------------------------
  6.  
  7.  
  8. #ifndef __SPRITEFRAME__
  9. #define __SPRITEFRAME__
  10.  
  11.  
  12. #ifndef __QDOFFSCREEN__
  13. #include <QDOffscreen.h>
  14. #endif
  15.  
  16. #ifndef __SWCOMMON__
  17. #include <SWCommonHeaders.h>
  18. #endif
  19.  
  20. #ifndef __BLITPIXIEINTERFACE__
  21. #include <BlitPixieInterface.h>
  22. #endif
  23.  
  24. typedef RLEPixelDataHdl        RLETokenHandle;
  25. typedef Ptr                    RLETokenPtr;
  26.  
  27. typedef Handle                CompiledHandle;
  28. typedef Ptr                    CompiledPtr;
  29.  
  30. #ifdef __cplusplus
  31. extern "C" {
  32. #endif
  33.  
  34. #if PRAGMA_ALIGN_SUPPORTED
  35. #pragma options align=mac68k
  36. #endif
  37.  
  38. ///--------------------------------------------------------------------------------------
  39. //    frame macros
  40. ///--------------------------------------------------------------------------------------
  41.  
  42. #define SWGetPixBaseAddr(pm)            GetPixBaseAddr(pm)            // ((**pm).baseAddr)
  43. #define SWGetPixRowBytes(pm)            ((**pm).rowBytes & 0x3FFF)    // GetPixRowBytes(pm)
  44. #define SWGetPixBitDepth(pm)            ((**pm).pixelSize)
  45.  
  46. ///--------------------------------------------------------------------------------------
  47. //    frame data structure
  48. ///--------------------------------------------------------------------------------------
  49.  
  50. struct FrameRec
  51. {
  52.     CGrafPtr         framePort;        // GWorld/CPort for the frame image
  53.     GDHandle        frameDevice;    // GDevice for the frame image
  54.     PixMapHandle     framePixHndl;    // PixMap for the frame image
  55.     PixMapPtr         framePix;        // pointer color pix map (valid only while locked)
  56.     
  57.     char*             frameBaseAddr;      // base address of pixel data (valid only while locked)
  58.     unsigned long     frameRowBytes;      // number of bytes in a row of the frame
  59.     short             leftAlignFactor;  // used to align rect.left to the nearest long word 
  60.     short             rightAlignFactor; // used to align rect.right to the nearest long word
  61.  
  62.     Boolean         isFrameLocked;      // has the frame been locked?
  63.     Boolean            isWindowFrame;      // is this a window Frame?
  64.     Boolean            interlacingIsOn;  // skip every other line?
  65.     Boolean            skipOddLines;      // skip odd lines (true), or even lines (false)?    
  66.     
  67.     short            frameDepth;        // frame image pixel size
  68.     Rect             frameRect;        // source image rectangle
  69.     short            hotSpotH;        // horizontal hot point for this frame
  70.     short            hotSpotV;        // vertical hot point for this frame
  71.     Rect            collisionInset;    // if used, makes the collision rect smaller/large for this frame
  72.  
  73.     Point             offsetPoint;    // offset for this Frame's maskRgn - used when calling OffsetRgn just before drawing the Sprite.
  74.     RgnHandle         maskRgn;        // image masking region, or NULL
  75.  
  76.     CGrafPtr        maskPort;        // GWorld/CPort for the mask image
  77.     GDHandle        maskDevice;        // GDevice for the mask image
  78.     PixMapHandle     maskPixHndl;    // PixMap for the mask image
  79.     PixMapPtr         maskPix;        // pointer to color pix map (valid only while locked)
  80.  
  81.     char*             maskBaseAddr;    // base address of mask pixel data (valid only while locked)
  82.     Boolean            tileMaskIsSolid;// used by SWDrawTilesAboveSprite
  83.     Boolean         sharesGWorld;    // shares GWorld with other frames
  84.     Boolean            usesCollisionInset;    // True if a collisionInset is used.
  85.     char            pad;
  86.     
  87.     unsigned short    useCount;          // number of sprites using this frame
  88.     short            worldRectOffset;  // non-whole-byte offset for all-bit blitter
  89.  
  90.     unsigned short     numScanLines;      // number of scan lines
  91.     unsigned short     pixelShift;          // amount to left-shift pixels to get bytes
  92.     unsigned long*     scanLinePtrArray; // array of offsets to each scanline
  93.     
  94.     RLETokenHandle    rleDataH;        // handle to RLE token data (shared by all sprite's frames)
  95.     RLETokenPtr        rleTokenStart;    // start of this frame's tokens (valid only while locked)
  96.     
  97. #if SW_68K
  98.     CompiledHandle     pixCodeH;        // handle to compiled sprite data
  99.     CompiledPtr     frameBlitterP;    // procPtr to draw compiled sprite (valid only while locked)
  100. #endif
  101.     
  102.     long            userData;        // reserved for user
  103. };
  104.  
  105.  
  106. ///--------------------------------------------------------------------------------------
  107. //    frame flags constants
  108. ///--------------------------------------------------------------------------------------
  109.  
  110. typedef enum
  111. {
  112.     kNoMask = 0,
  113.     kPixelMask = 1,
  114.     kRegionMask = 2,
  115.     kFatMask = (kPixelMask + kRegionMask),
  116.     kSolidMask = 4
  117. } MaskType;
  118.  
  119.     // Definitions for use with SWCreateFrame
  120. #define kCreateGWorld        true
  121. #define kDontCreateGWorld    false
  122.  
  123.     // Definitions for use with SWSetFrameInterlacingMode
  124. #define kSkipOddLines        true
  125. #define kSkipEvenLines        false
  126.  
  127.  
  128. ///--------------------------------------------------------------------------------------
  129. //    frame function prototypes
  130. ///--------------------------------------------------------------------------------------
  131.  
  132. SW_FUNC OSErr SWCreateFrame(
  133.     GDHandle     theGDH, 
  134.     FramePtr*     newFrameP, 
  135.     Rect* frameRect,
  136.     short depth,
  137.     Boolean createGWorld);
  138.  
  139. SW_FUNC OSErr SWCreateWindowFrame(
  140.     CWindowPtr    srcWindowP,
  141.     FramePtr* newFrameP,
  142.     Rect*     frameRect,
  143.     short     maxHeight);
  144.  
  145. SW_FUNC OSErr SWCreateFrameFromCicnResource(
  146.     SpriteWorldPtr     destSpriteWorld, 
  147.     FramePtr*         newFrameP, 
  148.     short             iconResID, 
  149.     MaskType         maskType);
  150.  
  151. SW_FUNC OSErr SWCreateFrameFromPictResource(
  152.     SpriteWorldPtr destSpriteWorld,
  153.     FramePtr*         newFrameP, 
  154.     short             pictResID, 
  155.     short             maskResID, 
  156.     MaskType         maskType);
  157.  
  158. SW_FUNC OSErr SWCreateFrameFromGWorldAndRect(
  159.     FramePtr*     newFrameP, 
  160.     GWorldPtr     pictGWorld, 
  161.     GWorldPtr     maskGWorld, 
  162.     Rect*         frameRect, 
  163.     MaskType     maskType);
  164.  
  165. SW_FUNC OSErr SWCreateFrameFromGWorldAndRectStart(
  166.     GWorldPtr     *tempMaskGWorld,
  167.     short         maxWidth,
  168.     short         maxHeight,
  169.     MaskType     maskType);
  170.  
  171. SW_FUNC OSErr SWCreateFrameFromGWorldAndRectPartial(
  172.     FramePtr*     newFrameP,
  173.     GWorldPtr     pictGWorld,
  174.     GWorldPtr     maskGWorld,
  175.     GWorldPtr     tempMaskGWorld,
  176.     Rect*         frameRect,
  177.     MaskType     maskType);
  178.     
  179. SW_FUNC void SWCreateFrameFromGWorldAndRectFinish(
  180.     GWorldPtr tempMaskGWorld);
  181.  
  182. SW_FUNC Boolean SWDisposeFrame(
  183.     FramePtr *oldFramePP);
  184.  
  185. SW_FUNC void SWDisposeWindowFrame(
  186.     FramePtr *oldFramePP);
  187.  
  188. SW_FUNC void SWSetPortToFrame(
  189.     FramePtr dstFrameP);
  190.  
  191. SW_FUNC Boolean SWAlignFrameToWindow(
  192.     FramePtr dstFrameP,
  193.     FramePtr windowFrameP);
  194.  
  195. SW_FUNC void SWInitializeFrame(
  196.     FramePtr     tempFrameP);
  197.  
  198. SW_FUNC void SWSetFrameMaskRgn(
  199.     FramePtr     srcFrameP, 
  200.     RgnHandle     maskRgn);
  201.  
  202. SW_FUNC void SWSetFrameHotSpot(
  203.     FramePtr srcFrameP,
  204.     short hotSpotH,
  205.     short hotSpotV);
  206.  
  207. SW_FUNC void SWSetFrameCollisionInset(
  208.     FramePtr srcFrameP,
  209.     short leftInset,
  210.     short topInset,
  211.     short rightInset,
  212.     short bottomInset);
  213.  
  214. SW_FUNC void SWSetFrameInterlacingMode(
  215.     FramePtr dstFrameP,
  216.     Boolean skipEveryOtherLine,
  217.     Boolean skipOddLines);
  218.  
  219. SW_FUNC OSErr SWCopyFrame(
  220.     SpriteWorldPtr destSpriteWorldP,
  221.     FramePtr oldFrameP, 
  222.     FramePtr *newFrameP,
  223.     Boolean copyMasks);
  224.  
  225. SW_FUNC OSErr SWUpdateFrameMasks(
  226.     FramePtr srcFrameP);
  227.  
  228. SW_FUNC void SWLockFrame(
  229.     FramePtr srcFrameP);
  230.  
  231. SW_FUNC void SWUnlockFrame(
  232.     FramePtr srcFrameP);
  233.  
  234. SW_FUNC void SWLockWindowFrame(
  235.     FramePtr windowFrameP);
  236.     
  237. SW_FUNC void SWUnlockWindowFrame(
  238.     FramePtr windowFrameP);
  239.  
  240. #if PRAGMA_ALIGN_SUPPORTED
  241. #pragma options align=reset
  242. #endif
  243.  
  244. #ifdef __cplusplus
  245. }
  246. #endif
  247.  
  248. #endif    /* __SPRITEFRAME__ */